﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class professorDetail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        BZZ.DataAcess worker = new BZZ.DataAcess();
        string id = Request.QueryString["id"];
        try
        {
            Convert.ToInt32(id);
        }
        catch
        {
            LIB.JsWrite.AlertAndGoback(this, "非法的参数。");
        }
        string sql = "select top 1 * from professor where id=" + id;
        DataSet dset = worker.Execute(sql);
        if (dset != null)
        {
            #region 作者相关信息
            DataRow row = dset.Tables[0].Rows[0];
            string realname = row["realname"].ToString();
            string picurl = row["picurl"].ToString();
            string about = row["about"].ToString();
            picurl = "img/" + picurl;
            litContent.Text = about;
            litProssorPic.Text = "<a href='" + picurl.Replace("thumb/", "") + "' target=_blank><img src='" + picurl + "' width=130 border=0></a>";
            litRealName.Text = realname; 
            #endregion

            #region 产品列表信息
            sql = "select * from product where professorID=" + id;
            dset = worker.Execute(sql);
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("            <table width=\"800\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">");
            //sb.Append("              <tr>");
            bool trBegin = false;
            int rowCount = dset.Tables[0].Rows.Count;
            for (int i = 0; i < rowCount; i++)
            {
                #region 内容拼接
                row = dset.Tables[0].Rows[i];
                string varid = row["id"].ToString().Trim();
                string varPicURL = row["picURL"].ToString().Trim();//图片地址
                string varProductCode = row["productCode"].ToString().Trim();//作品编号
                string varProfessorID = row["professorID"].ToString().Trim();//作者姓名
                string varTitle = row["title"].ToString().Trim();//作品名称
                string varMaterial = row["material"].ToString().Trim();//作品材质
                string varSize = row["size"].ToString().Trim();//作品规格
                string varPrice = row["price"].ToString().Trim();//作品标价
                string varSale = row["sale"].ToString().Trim();//销售情况
                string varAbout = row["about"].ToString().Trim();//作品介绍
                string varMemo = row["memo"].ToString().Trim();//备注信息
                string varPubDate = row["pubDate"].ToString().Trim();//添加时间
                string varSortid = row["sortid"].ToString().Trim();//排序
                string varIsRecommend = row["isRecommend"].ToString().Trim();//是否推荐
                varPicURL = "img/" + varPicURL;
                if (i % 4 == 0)
                {
                    sb.Append("<tr>");
                    trBegin = true;
                }
                sb.Append("                <td width=\"200\" align=\"left\" valign=\"top\">");

                sb.Append("                <table width=\"166\" border=\"0\" align=\"left\" cellpadding=\"5\" cellspacing=\"0\">");
                sb.Append("                  <tr>");
                sb.Append("                    <td colspan=\"2\" align=\"center\" valign=\"top\"><table width=\"148\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#cfcfb8\">");
                sb.Append("                        <tr>");

                //sb.Append("                          <td align=\"center\" valign=\"top\" bgcolor=\"#FFFFFF\"><a href=\"ProductDetail.aspx?id=" + varid + "\"><img src=\"" + varPicURL + "\" width=\"136\" height=\"104\" border=\"0\"></a></td>");

                sb.Append("                          <td align=\"center\" valign=\"top\" bgcolor=\"#FFFFFF\">");

                sb.Append("<div class=\"thumbnail\">");
                sb.Append("    <a rel=\"lightbox\" href=\"" + varPicURL + "\">");
                sb.Append("    </a>");
                sb.Append("    <a rel=\"lightbox\" href=\"" + varPicURL + "\" title=\"\">");
                sb.Append("        <img id='pic1' src=\"" + varPicURL + "\" width=\"136\" height=\"104\"  onload=\"javascript:DrawImage2(this);\"");
                sb.Append("        border=\"0\" style=\"border:3px solid #EEE\">");
                sb.Append("    </a>");
                sb.Append("</div>");
                
                //sb.Append("<img src=\"" + varPicURL + "\" width=\"136\" height=\"104\" border=\"0\">");
                sb.Append("</td>");
                


                //sb.Append("                          <td align=\"center\" valign=\"top\" bgcolor=\"#FFFFFF\"><a href=\"" + varPicURL.Replace("Thumb/", "") + "\" target=_blank><img src=\"" + varPicURL + "\" width=\"136\" height=\"104\" border=\"0\"></a></td>");
                sb.Append("                        </tr>");
                sb.Append("                    </table></td>");
                sb.Append("                    </tr>");
                sb.Append("                  <tr>");
                sb.Append("                    <td width=\"4\" align=\"center\" valign=\"top\" class=\"zt01\">&nbsp;</td>");
                sb.Append("                    <td width=\"142\" align=\"left\" valign=\"top\" class=\"zt01\">编号：" + varProductCode + " </td>");
                sb.Append("                  </tr>");
                sb.Append("                  <tr>");
                sb.Append("                    <td align=\"center\" valign=\"top\" class=\"zt01\">&nbsp;</td>");
                sb.Append("                    <td align=\"left\" valign=\"top\" class=\"zt01\">品名：" + varTitle + "</td>");
                sb.Append("                  </tr>");
                sb.Append("                  <tr>");
                sb.Append("                    <td align=\"center\" valign=\"top\" class=\"zt01\">&nbsp;</td>");
                sb.Append("                    <td align=\"left\" valign=\"top\" class=\"zt01\">规格：" + varSize + "</td>");
                sb.Append("                  </tr>");
                sb.Append("                  <tr>");
                sb.Append("                    <td align=\"center\" valign=\"top\" class=\"zt01\">&nbsp;</td>");
                sb.Append("                    <td align=\"left\" valign=\"top\" class=\"zt01\">售价：" + varPrice + "</td>");
                sb.Append("                  </tr>");
                sb.Append("                  <tr>");
                sb.Append("                    <td align=\"center\" valign=\"top\" class=\"zt01\">&nbsp;</td>");
                sb.Append("                    <td align=\"left\" valign=\"top\" class=\"zt01\">状态：" + varSale + "</td>");
                sb.Append("                  </tr>");
                sb.Append("                </table></td>");
                if (i % 4 == 3)
                {
                    sb.Append("</tr>");
                    trBegin = false;
                }
                #endregion

            }
            if (trBegin)
            {
                for (int t = 0; t < rowCount % 4; t++) sb.Append("<td width=\"200\">&nbsp;</td>");
                sb.Append("</tr>");
            }
            sb.Append("              <tr>");
            sb.Append("                <td colspan=\"4\" align=\"right\" valign=\"top\" class=\"zt01\">&nbsp;</td>");
            sb.Append("              </tr>");
            //sb.Append("              <tr>");
            //sb.Append("                <td colspan=\"4\" align=\"right\" valign=\"top\" class=\"zt01\">共有4条 首页　上一页 下一页　尾页 页次:1/1页 12条/页</td>");
            //sb.Append("                </tr>");
            sb.Append("            </table>"); 
            #endregion
            litProduct.Text = sb.ToString();
        }
    }
}
